package com.hospes.rmes.models;

import android.os.Parcel;
import android.os.Parcelable;
import com.hospes.rmes.utils.Utils;

import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Andrew Khloponin
 * Date: 17.06.11
 */
public class News implements Cloneable, Parcelable {
	public int nid;
	public Date date;
	public String title;
	public String files;
	public String text;
	public String teaser;

	public News() {
		nid = -1;
	}

	public News(Date date, String title, String files, String text, String teaser) {
		nid = -1;
		this.date = date;
		this.title = title;
		this.files = files;
		this.text = text;
		this.teaser = teaser;
	}

	// Setters
	public void setNid(int nid) {
		this.nid = nid;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setFiles(String files) {
		this.files = files;
	}

	public void setText(String text) {
		this.text = text;
	}

	public void setTeaser(String teaser) {
		this.teaser = teaser;
	}

	// Getters
	public int getNid() {
		return nid;
	}

	public Date getDate() {
		return date;
	}

	public String getTitle() {
		return title;
	}

	public String getFiles() {
		return files;
	}

	public String getText() {
		return text;
	}

	public String getTeaser() {
		return teaser;
	}

	public News(Parcel in) {
		readFromParcel(in);
	}

	public int describeContents() {
		return 0;
	}

	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(nid);
		dest.writeString(Utils.FromDateToString(date));
		dest.writeString(title);
		dest.writeString(files);
		dest.writeString(text);
		dest.writeString(teaser);
	}

	private void readFromParcel(Parcel in) {
		nid = in.readInt();
		date = Utils.FromStringToDate(in.readString());
		title = in.readString();
		files = in.readString();
		text = in.readString();
		teaser = in.readString();
	}

	public static final Parcelable.Creator<News> CREATOR = new Parcelable.Creator<News>() {
		public News createFromParcel(Parcel in) {
			return new News(in);
		}

		public News[] newArray(int size) {
			return new News[size];
		}
	};
}
